package com.waiting.leetcode;

/**
 * @Description
 * @Author bjweitingting
 * @Date 2019/3/22
 **/
public class bit1And2bitCharacters717 {
    public static void main(String[] args) {

    }

    public boolean isOneBitCharacter(int[] bits) {
        int n = bits.length;
        for (int i = 0; i < bits.length; ) {
            if (i == bits.length - 1)
                return true;
            if (bits[i] == 1)
                i += 2;
            else if (bits[i] == 0)
                i += 1;
        }
        return false;
    }
    public boolean isOneBitCharacter2(int[] bits) {
        int len = bits.length;
        if(bits[len-1] == 1) return false;

        int countOne = 0;
        for(int i = len - 2; i >= 0; i--){
            if(bits[i] == 0) break;
            countOne++;
        }

        if(countOne % 2 == 0){
            return true;
        }

        return false;
    }
}
